﻿using KMSimulator.Model;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Windows.Input;

namespace BarrageGameAssistant.UIForms
{
    public partial class FrmKeyboardAction : Form
    {
        private bool _newFlag = true; //新建标记

        #region 属性

        /// <summary>
        /// 键盘动作
        /// </summary>
        public KMActionBase? KeyboardAction { get; set; }
        #endregion

        public FrmKeyboardAction()
        {
            InitializeComponent();
        }

        private void FrmKeyboardAction_Load(object sender, EventArgs e)
        {
            cbbActionType.SelectedIndex = 0;
            txtKeyboard.Text = "";
            txtKeyboard1.Text = "";
            txtInputText.Enabled = false;
            cbbExecuteMode.SelectedIndex = 0;
            nudExecuteCount.Value = 1;
            nudInterval.Value = 100;
            nudReleaseTime.Value = 100;
            nudDelay.Value = 100;


            if (KeyboardAction == null)
            {
                _newFlag = true;
            }
            else
            {
                _newFlag = false;
            }
        }

        private void cbbActionType_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cbbActionType.SelectedIndex == 0)
            {
                btnResetKeyboard.Enabled = true;
                btnResetKeyboard1.Enabled = true;
                txtKeyboard.Enabled = true;
                txtKeyboard1.Enabled = true;
                txtInputText.Enabled = false;
            }
            else
            {
                btnResetKeyboard.Enabled = false;
                btnResetKeyboard1.Enabled = false;
                txtKeyboard.Enabled = false;
                txtKeyboard1.Enabled = false;
                txtInputText.Enabled = true;
            }
        }

        private void btnResetKeyboard_Click(object sender, EventArgs e)
        {
            this.txtKeyboard.Reset();
        }

        private void btnResetKeyboard1_Click(object sender, EventArgs e)
        {
            this.txtKeyboard1.Reset();
        }
    }
}
